﻿<UserControl x:Class="StockholmsStad.Windows.UI.Modules.Maintenance.Controls.ParvisUserDetailsControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:converters="clr-namespace:StockholmsStad.Windows.UI.Infrastructure.Converters;assembly=StockholmsStad.Windows.UI.Infrastructure"
    xmlns:customControls="clr-namespace:StockholmsStad.Windows.UI.Infrastructure.Controls;assembly=StockholmsStad.Windows.UI.Infrastructure"
    >
    <UserControl.Resources>
        <converters:UserRoleToStringConverter x:Key="enumConverter" />
        <converters:NullableBoolToOppositeBoolConverter x:Key="boolToOppositeBool" />
    </UserControl.Resources>

    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="*" />
        </Grid.RowDefinitions>

        <GroupBox Grid.Row="0" Padding="5,5,5,5" Header="Användare">

            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="10"></ColumnDefinition>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="Auto"></ColumnDefinition>
                    <ColumnDefinition Width="*"></ColumnDefinition>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                    <RowDefinition />
                </Grid.RowDefinitions>

                <Label Grid.Row="0" Grid.Column="0" Content="Förnamn:" />
                <Label Grid.Row="1" Grid.Column="0" Content="Efternamn:" />
                <Label Grid.Row="2" Grid.Column="0" Content="Användarnamn:" />
                <Label Grid.Row="3" Grid.Column="0" Content="Telefon:" />
                <Label Grid.Row="4" Grid.Column="0" Content="Mobil:" />
                <Label Grid.Row="5" Grid.Column="0" Content="Behörighet:" />
                <Label Grid.Row="6" Grid.Column="0" Content="Aktiv:" />

                <TextBox Grid.Row="0" Grid.Column="2" x:Name="TextBoxFirstName" Width="200"
                         Text="{Binding FirstName, Mode=TwoWay, UpdateSourceTrigger=Explicit, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
                                 Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" />
                <Label Grid.Row="0" Grid.Column="3" Content="*"></Label>

                <TextBox Grid.Row="1" Grid.Column="2" x:Name="TextBoxLastName" Width="200" 
                         Text="{Binding LastName, Mode=TwoWay, UpdateSourceTrigger=Explicit, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
                                 Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" />
                <Label Grid.Row="1" Grid.Column="3" Content="*"></Label>

                <TextBox Grid.Row="2" Grid.Column="2" x:Name="TextBoxUserName" Width="200"
                         Text="{Binding EmailAddress, Mode=TwoWay, UpdateSourceTrigger=Explicit, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
                                 Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" />
                <Label Grid.Row="2" Grid.Column="3" Content="*"></Label>

                <TextBox Grid.Row="3" Grid.Column="2" x:Name="TextBoxPhoneNumber" Width="200"
                         Text="{Binding PhoneNumber, Mode=TwoWay, UpdateSourceTrigger=Explicit, ValidatesOnExceptions=True, NotifyOnValidationError=True, ValidatesOnDataErrors=True}"
                                 Validation.ErrorTemplate="{DynamicResource ErrorTemplate}" Style="{DynamicResource TextBoxInError}" />
                <Label Grid.Row="3" Grid.Column="3" Content="*"></Label>

                <TextBox Grid.Row="4" Grid.Column="2" x:Name="TextBoxCellPhone" Width="200"
                         Text="{Binding CellPhoneNumber, Mode=TwoWay, UpdateSourceTrigger=Explicit}" />
                
                <ComboBox x:Name="ComboBoxUserRole" Grid.Row="5" Grid.Column="2"  Width="200"
                      SelectedItem="{Binding UserRole, UpdateSourceTrigger=Explicit}" >
                    <ComboBox.ItemTemplate>
                        <DataTemplate>
                            <TextBlock Text="{Binding Converter={StaticResource enumConverter}}" />
                        </DataTemplate>
                    </ComboBox.ItemTemplate>
                </ComboBox>
                <Label Grid.Row="5" Grid.Column="3" Content="*"></Label>

                <StackPanel Orientation="Horizontal" Grid.Row="6" Grid.Column="2" >
                    <customControls:ExtendedRadioButton x:Name="rbActiveYes" Content="Ja" GroupName="Active" Padding="5,0,0,0" Margin="0,0,10,0"
                                 VerticalAlignment="Center" IsCheckedReal="{Binding IsActive, Mode=TwoWay}" />

                    <customControls:ExtendedRadioButton x:Name="rbActiveNo" Content="Nej" GroupName="Active" Padding="5,0,0,0"
                                 VerticalAlignment="Center" IsCheckedReal="{Binding IsActive, Mode=TwoWay, Converter={StaticResource boolToOppositeBool}}" />

                </StackPanel>

                <StackPanel Orientation="Vertical" Grid.Row="7" Grid.Column="0" Grid.ColumnSpan="5">
                    <StackPanel Margin="0,20,0,0" HorizontalAlignment="Left" Orientation="Horizontal">
                        <Button x:Name="ChangePasswordButton" Content="Skicka lösenord" Command="{Binding ChangePasswordCommand}" Visibility="Visible" Margin="0,0,5,0" />
                        <Button x:Name="DeleteButton" Content="Ta bort" Click="DeleteButton_Click" Visibility="Visible" Margin="0,0,5,0" />
                        <Button x:Name="CancelButton" Content="Ångra" Click="CancelButton_Click" Visibility="Collapsed" Margin="0,0,5,0" />
                        <Button x:Name="SaveButton" Content="Spara" Click="SaveButton_Click" Visibility="Collapsed" />
                    </StackPanel>

                    <StackPanel Margin="0,20,0,0" HorizontalAlignment="Left" Orientation="Horizontal">
                        <Button x:Name="AddButton" Content="Ny användare" Command="{Binding AddCommand}" Click="AddButton_Click" Margin="0,0,10,0" />
                    </StackPanel>
                
                </StackPanel>

            </Grid>

        </GroupBox>

    </Grid>
</UserControl>
